package main

import (
	"google.golang.org/grpc"
	"log"
	"learngo/grpc/proto"
	"context"
	"fmt"
)

func main() {

	// 实例化 UserInfoService 微服务的客户端
	conn,err := grpc.Dial(":9666",grpc.WithInsecure())

	if err != nil {
		log.Fatalf("dial error: %v\n", err)
	}

	defer conn.Close()

	client := proto.NewUserInfoServiceClient(conn)

	// 调用服务
	req := new(proto.UserRequest)
	req.Name = "rovast"

	resp,err := client.GetUserInfo(context.Background(),req)

	if err != nil {
		log.Fatalf("resp error: %v\n", err)
	}
	fmt.Printf("Recevied: %v\n", resp)

}
